﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace Face8280WebSocketServer.Utility
{
    public class ThrowHelper
    {
        /// <summary>
        /// 其他用户可处理的异常的基本类 
        /// </summary>
        /// <param name="message"></param>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public static void SystemException(string message)
        {
            throw GetSystemException();

            SystemException GetSystemException()
            {
                return new SystemException(message);
            }
        }
        /// <summary>
        /// 方法的参数是非法的 
        /// </summary>
        /// <param name="message"></param>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public static void ArgumentException(string message)
        {
            throw GetArgumentException();

            ArgumentException GetArgumentException()
            {
                return new ArgumentException(message);
            }
        }
        /// <summary>
        /// 一个空参数传递给方法，该方法不能接受该参数 
        /// </summary>
        /// <param name="message"></param>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public static void ArgumentNullException(string message)
        {
            throw GetArgumentNullException();

            ArgumentNullException GetArgumentNullException()
            {
                return new ArgumentNullException(message);
            }
        }

        /// <summary>
        /// 试图使用一个未分配的引用 
        /// </summary>
        /// <param name="message"></param>
        [MethodImpl(MethodImplOptions.NoInlining)]
        public static void NullReferenceException(string message)
        {
            throw GetNullReferenceException();

            NullReferenceException GetNullReferenceException()
            {
                return new NullReferenceException(message);
            }
        }
    }
}
